﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Wheeler.Common.Extensions;
using Wheeler.Domain;
using Wheeler.Web.ViewModels;
using Wheeler.Web.Utility;
using AutoMapper;
using System.Web.Script.Serialization;
using System.Text;

namespace Wheeler.Web.Controllers
{
    public class AjaxController : BaseController
    {
        private WheelerEntities _Context;
        
		#region Constructors
		public AjaxController()
		{
            _Context = new WheelerEntities();
		}

		public AjaxController(UserViewModel currentUser)
			: base(currentUser)
        {
            _Context = new WheelerEntities();
        }
		#endregion Constructors

		#region Action Methods

        /// <summary>
        /// Deletes a temporary image by the given path. This is typically /Tmp
        /// </summary>
        /// <param name="imagePath"></param>
        /// <returns></returns>
        [HttpPost]
        public bool DeleteTempImage(String imagePath)
        {
            String fileName = System.IO.Path.GetFileName(imagePath);            
            fileName = System.IO.Path.Combine(Server.MapPath(AppConstants.Directories.TEMP), fileName);
            if (System.IO.File.Exists(fileName))
            {
                System.IO.File.Delete(fileName);
                return true;
            }
            return false;
        }
		#endregion Action Methods
		
		#region Helper Methods

        #endregion			
    }
}
